package main

import "fmt"

// 多态性

type notifier interface {
	notify()
}

type user struct {
	name string
	email string
}

func (u *user) notify() {
	fmt.Printf("Sending user email to %s<%s>\n",
		u.name,
		u.email)
}

type admin struct {
	name string
	email string
}

func (a *admin)notify() {
	fmt.Printf("Sending admin email to %s<%s>\n",
		a.name,
		a.email)
}

func sendNotification(n notifier)  {
	n.notify()
}

func main() {
	hello := user{name: "hello", email: "xxxxx@qq.com"}
	admin := admin{name: "admin", email: "admin123@qq.com"}
	sendNotification(&hello)
	sendNotification(&admin)
}